package com.pro.controller;

import com.pro.pojo.JsLoginRecord;
import com.pro.pojo.JsUser;
import com.pro.pojo.JsonData;
import com.pro.service.JsLoginRecordService;
import com.pro.utils.IPAndAddressUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author cyj
 * @date 2022.1.20$ 18.36$
 * @content :
 */
@Controller
@RequestMapping("/loginRecord")
public class JsLoginRecordController {
    @Autowired
    private JsLoginRecordService service;
    /**
     * @author CYJ
     * @date 2022/1/20 18.56
     * @content : 查询登录日志
     */
    @RequestMapping("/getJsLoginRecord")
    @ResponseBody
    public JsonData getJsLoginRecord(Integer page,Integer limit) {
        List<JsLoginRecord> list = service.getJsLoginRecord(page,limit);
        int count = service.count();
        System.err.println(count);
        return list!=null?JsonData.buildSuccess(list,count):JsonData.buildError("服务器错误");
    }

    /**
     * @author CYJ
     * @date 2022/2/9 10.22
     * @content : 登录日志计数
     */
    public JsonData count() {
        int i = service.count();
        return i >= 0 ?JsonData.buildSuccess(i):JsonData.buildError("服务端错误");
    }
}
